package cn.edu.sdjzu.xg23.kcsj01_backend.controller;

import cn.edu.sdjzu.xg23.kcsj01_backend.controller.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.entity.LiteratureDatabase;
import cn.edu.sdjzu.xg23.kcsj01_backend.service.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.utils.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.entity.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.mapper.*;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
public class JournalController {
    @Autowired
    private JournalService journalService;

    @GetMapping("/journal")
    public Result get(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody(required = false) Journal journal) {

        PageInfo<Journal> journalPageInfo = journalService.get(pageNum, pageSize, journal);
        System.out.println(journalPageInfo);
        return Result.success(journalPageInfo);
    }

    @PostMapping("journal")
    public Result save(@RequestBody Journal journal) {
        return Result.success(journalService.save(journal));
    }

    @PutMapping("journal")
    public Result update(@RequestBody Journal journal) {
        return Result.success(journalService.update(journal));
    }

    @DeleteMapping("journal/{id}")
    public Result delete(@PathVariable long id) {
        return Result.success(journalService.delete(id));
    }
}
